package com.itheima.JDBC.C3p0;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class demo03 {
    public static void main(String[] args) {
        Connection connection = C3P0Utils.getConnection();
        String sql = "select *from emp";
        PreparedStatement statement = null;
        ResultSet resultSet = null;
        try {
            statement = connection.prepareStatement(sql);
            resultSet = statement.executeQuery();
            while (resultSet.next()) {
                System.out.println(resultSet.getString("ename"));
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            try {
                if (resultSet != null) {
                    resultSet.close();
                    resultSet = null;
                }
            } catch (SQLException e) {
                e.printStackTrace();
            } finally {
                C3P0Utils.release(connection, statement);
            }
        }
    }
}
